package cn.wen233.srpc.core.utils;

import cn.wen233.srpc.basic.exception.BaseException;
import lombok.extern.slf4j.Slf4j;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * IP工具类
 *
 * @author wenjie
 * @date 2022-03-21 15:56
 */
@Slf4j
public class IpUtils {

    public static String localIp() {
        try {
            return InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            log.error("获取主机ip失败", e);
        }
        throw new BaseException("获取注解ip失败");
    }
}
